/*    */ package com.hp.bon.sgw.core.channel.handler;
/*    */ 
/*    */ import cn.chinatelecom.sgw.soap.SgwQueryReq;
/*    */ import com.hp.bon.sgw.bean.XmlMessage;
/*    */ import com.hp.bon.sgw.core.BuzProcessorManager;
/*    */ import com.hp.bon.sgw.core.CallParam;
/*    */ import com.hp.bon.sgw.core.channel.SCSPChannel;
/*    */ import com.hp.bon.sgw.core.channel.SoapChannel;
/*    */ import com.hp.bon.sgw.scsp.SCSPUtils;
/*    */ import com.hp.ocs.diameter.message.Message;
/*    */ import java.text.SimpleDateFormat;
/*    */ import org.apache.mina.core.session.IoSession;
/*    */ import org.dom4j.Element;
/*    */ import org.slf4j.Logger;
/*    */ import org.slf4j.LoggerFactory;
/*    */ 
/*    */ public class SCSPAsynCallHandler
/*    */   implements IAsynCallHandler
/*    */ {
/* 25 */   private static final Logger logger = LoggerFactory.getLogger(SCSPAsynCallHandler.class);
/*    */   IoSession session;
/*    */   SCSPChannel channel;
/*    */ 
/*    */   public SCSPAsynCallHandler(IoSession session, SCSPChannel channel)
/*    */   {
/* 28 */     this.session = session;
/* 29 */     this.channel = channel;
/*    */   }
/*    */ 
/*    */   public void onCallResult(CallParam callParam)
/*    */   {
/* 37 */     XmlMessage sgwQueryAck = null;
/* 38 */     if (callParam.getResponse() == null) {
/* 39 */       sgwQueryAck = SoapChannel.createERRAnwser(callParam.getSessionId(), callParam.getRetCode() == 3002 ? 11206 : callParam.getRetCode(), callParam.getResultMsg());
/*    */     }
/* 41 */     else if ((callParam.getResponse() instanceof Message))
/* 42 */       sgwQueryAck = BuzProcessorManager.getInstance().convertMessageToAck(callParam);
/* 43 */     else if ((callParam.getResponse() instanceof XmlMessage))
/* 44 */       sgwQueryAck = (XmlMessage)callParam.getResponse();
/*    */     else {
/* 46 */       logger.warn("unknown response type:" + callParam.getResponse().getClass().getName());
/*    */     }
/*    */ 
/* 49 */     Element rootSCA = this.channel.createSCA((SgwQueryReq)callParam.getRequest());
/* 50 */     SCSPUtils.addElement(rootSCA, "DATA", sgwQueryAck.getDataElement());
/* 51 */     SCSPUtils.addElement(rootSCA, "SIG", sgwQueryAck.getSIG());
/* 52 */     SCSPUtils.addElement(rootSCA, "DS", sgwQueryAck.getDS());
/* 53 */     SCSPUtils.addElement(rootSCA, "RC", sgwQueryAck.getRC());
/* 54 */     SCSPUtils.addElement(rootSCA, "RTT", new SimpleDateFormat("yyyyMMddHHmmssSSS").format(Long.valueOf(System.currentTimeMillis())));
/*    */ 
/* 56 */     this.channel.sendMsg(this.session, rootSCA);
/*    */   }
/*    */ 
/*    */   public int getProtocolType()
/*    */   {
/* 61 */     return 2;
/*    */   }
/*    */ }

/* Location:           C:\Users\think\Desktop\sgw_2.1.jar
 * Qualified Name:     com.hp.bon.sgw.core.channel.handler.SCSPAsynCallHandler
 * JD-Core Version:    0.6.1
 */